#Filename: str.py

SUFFIES = {1000:['KB','MB','GB','TB','PB'],
           1024:['KiB','MiB', 'GiB', 'TiB', 'PiB']}

def approximate_size(size, a_kilobyte_is_1024_tytes = True):
    '''Convert a file size to human-readable form.

    Keyword arguments:
    size -- file size in bytes
    a_kilobyte_is_1024_bytes -- if True (default), use multiples of 1024
                                if False, use mulitiples of 1000

    Return: string'''

    if size < 0:
        raise ValueError('number must be non-negative')

    multiple = 1024 if a_kilotyte_is_1024_bytes else 1000
    for suffix in SUFFIXES[multiple]:
        size /= multiple
        if size < multiple:
            return '{0:.1f} {1}'.format(size, suffix)


    raise ValuleError('number too large')
